﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WoBian.Entities.Admin;
using WoBian.DA;
using System.Data;
using WoBian.ServiceModel;
namespace WoBian.Biz.Admin.User
{
    public class AdminUserBiz
    {
        public static string Save(AdminUser aAdminUser)
        {
            aAdminUser.CreateId = MyApplicationContext.Current.UserId;
            aAdminUser.CreateDate = DateTime.Now;
            IDbConnection connection = DataAccessFactory.CreateDbConnection();
            try
            {
                connection.Open();
                return DataAccessFactory.CreateAdminUserDAL(connection).Save(aAdminUser,WoBian.Lib.Enum.DbOperationType.Insert);
            }
            finally
            {
                connection.Close();
            }
        }

        public static AdminUser GetById(string aId)
        {
            IDbConnection connection = DataAccessFactory.CreateDbConnection();
            try
            {
                connection.Open();
                return DataAccessFactory.CreateAdminUserDAL(connection).GetById(aId);
            }
            finally
            {
                connection.Close();
            }
        }

        public static AdminUser GetByUserName(string UserName)
        {
            IDbConnection connection = DataAccessFactory.CreateDbConnection();
            try
            {
                connection.Open();
                return DataAccessFactory.CreateAdminUserDAL(connection).GetByUserName(UserName);
            }
            finally
            {
                connection.Close();
            }
        }
    }
}
